/*
day484 
2020.12.24 
*/
#include<iostream>
#include<deque>
#include<vector>
#include<cstring>
using namespace std;


class Solution {
public:
    string removeDuplicates(string S) {
    	if(S.size()<=1) return S;
		deque<char> que;
		que.push_back(S[0]);
		for(int i=1;i<S.size();++i)
		{
			if( que.empty() ||que.back()!=S[i])
			{
				que.push_back(S[i]);
			}
			else 
			{
				que.pop_back();
			}
		}
		
		string res(que.begin(),que.end());
		
		return res;
    }
};

int main()
{
	return 0;
}
